local config = require "config"
SERVICE_D:register(config.server.login_channel, function (linda, bytes)
    local ok, name, data = PROTOCOL_D:decode(bytes)
    if not ok then
        return
    end

    if data.timestamp + 60 < os.time() then
        spdlog.warn("login_channel", string.format("member[timestamp] too long, data : %s", data));
        return
    end

    if not data.agent_id then
        spdlog.warn("login_channel", string.format("member[agent_id] type error, data : %s", data));
        return
    end

    if not data.gate_channel then
        spdlog.warn("login_channel", string.format("member[gate_channel] type error, data : %s", data));
        return
    end

    local agent_ob = AGENT_OB:create()
    agent_ob:set_id(data.agent_id)
    agent_ob:set_gate_channel(data.gate_channel)
    agent_ob:set_login_info(data.login_info)
    agent_ob:set_login_time(os.time())
    LOGIN_D:login(agent_ob)
end)
